package com.cxl;

import com.cxl.dao.UserDao;
import com.cxl.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @author: 20971
 * @time: 2022/3/1 22:07
 * @description:
 */
//@RunWith(SpringRunner.class)
@SpringBootTest
public class Test {

    @Autowired
    private UserDao userDao;

    @org.junit.jupiter.api.Test
    public void add() {
//        List<User> all = userDao.findAll();
        User user = new User();
        user.setName("小崔");
        user.setAge(19.9);
        userDao.add(user);
        System.out.println("111");

    }


    @org.junit.jupiter.api.Test
    public void list() {
        List<User> all = userDao.findAll();
        System.out.println(all);
    }

    @org.junit.jupiter.api.Test
    public void update() {
        User user = new User();
        user.setName("小王");
        user.setAge(19.99);
        //注意,指定主键id
        user.setId(2);
        userDao.update(user);
    }

    @org.junit.jupiter.api.Test
    public void rem() {
        User user = new User();
        //注意,指定主键id
        user.setId(2);
        userDao.del(user);
    }


    @org.junit.jupiter.api.Test
    public void query() {
        List<User> users = userDao.queryUser();
        System.out.println(users);
    }

}
